package com.yyw.bean;

import java.util.Date;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "用户类User")
public class User {

    @ApiModelProperty("用户ID")
    private Long id;

    @ApiModelProperty("用户昵称")
    private String name;

    @ApiModelProperty("密码")
    private String password;

    @ApiModelProperty("用户类型")
    private Integer type;

    @ApiModelProperty("每日目标")
    private Integer target;

    @ApiModelProperty("当月累积达标数")
    private Integer accumulatemonth;

    @ApiModelProperty("当月时间")
    private Date monthdate;

    @ApiModelProperty("累积达标天数")
    private Integer accumulate;

    @ApiModelProperty("英语等级")
    private Integer level;

    @ApiModelProperty("性别")
    private String sex;

    @ApiModelProperty("手机号")
    private String tel;

    @ApiModelProperty("邮箱")
    private String email;

    @ApiModelProperty("班级ID")
    private Long classid;

    @ApiModelProperty("班级名称")
    private String classname;

    @ApiModelProperty("当日阅读数")
    private Integer daynum;

    @ApiModelProperty("当日时间")
    private Date daydate;

    public Boolean checkType() {
        if (this.type == null) {
            return false;
        }
        if (!this.type.equals(1) && !this.type.equals(2) && !this.type.equals(3)) {
            return false;
        }

        return true;
    }

    public void init() {
        if (daydate == null) {
            daydate = new Date();
        }
        if (daynum == null || daynum < 0) {
            daynum = 0;
        }
        if (monthdate == null) {
            monthdate = new Date();
        }
        if (accumulatemonth == null || accumulatemonth < 0) {
            accumulatemonth = 0;
        }
        if (accumulate == null || accumulate < 0) {
            accumulate = 0;
        }
    }
}
